package sort;

public class InsertionSort {
    public static int[] Sort(int[] arr) {
        if (arr.length == 0) {
            return null;
        }
        int n = arr.length;
        int preIndex, current;
        for (int i = 0; i < n; i++) {
            preIndex = i - 1;
            current = arr[i];
            while (preIndex >= 0 && arr[preIndex] > current) {
                arr[preIndex + 1] = arr[preIndex];
                preIndex--;
            }
            arr[preIndex + 1] = current;
        }
        return arr;
    }
}
